package gui.dialogs.dbspec;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created by:  Jason Ye
 * Date:        12/02/2012
 * Time:        14:32
 */
public class DatabaseSpecDialog extends JDialog implements ActionListener {

    private JLabel DBPageSizeLabel = new JLabel("DB Page Size: ");
    private JLabel DBFillFactorLabel = new JLabel("DB Fill Factor");

    private JButton okButton;
    private JButton cancelButton;

    private JTextField DBPageSizeEntryField;
    private JTextField DBFillFactorEntryField;


    public DatabaseSpecDialog(Frame owner, boolean modal) {

        super(owner, "Specify DB properties", modal);

        // init buttons
        okButton = new JButton("OK");
        cancelButton = new JButton("Cancel");

        //init textfields
        DBFillFactorEntryField = new JTextField(30);
        DBPageSizeEntryField = new JTextField(30);

        //add action listeners
        okButton.addActionListener(this);
        cancelButton.addActionListener(this);

        GridLayout layout = new GridLayout(3, 2);
        this.setLayout(layout);

        this.add(DBFillFactorLabel);
        this.add(DBFillFactorEntryField);
        this.add(DBPageSizeLabel);
        this.add(DBPageSizeEntryField);

        this.add(okButton);
        this.add(cancelButton);
        this.setSize(new Dimension(200, 200));

        setVisible(true);

    }

    @Override
    public void actionPerformed(ActionEvent actionEvent) {

        if (okButton == actionEvent.getSource()) {

            System.out.println("User chose OK.");
        } else if (cancelButton == actionEvent.getSource()) {
            System.out.println("User chose Cancel.");
        }
        setVisible(false);
    }


}
